package org.example.day12;

import java.util.Timer;
import java.util.TimerTask;

public class TimerDemo {
    public static void main(String[] args) {
        TimerTask timerTask = new TimerTask() {
            @Override
            public void run() {
                System.out.println("ThreadName = " + Thread.currentThread().getName() + " Time = " + System.currentTimeMillis());
                System.out.println("定时任务~");
            }
        };
        Timer timer = new Timer();
        long delay = 0;
        long period = 1000;
        //para1:任务逻辑
        //para2:延迟多长时间开始
        //para3:执行周期
        timer.scheduleAtFixedRate(timerTask,0,period);
    }
}
